package com.yangrong.thread.chapter8;

/**
 * Future设计模式
 * 
 * Future		->代表未来的一个凭据
 * FutureTask	->将调用逻辑进行隔离
 * FutureService->桥接Future和FutureTask
 * 
 * @author YangRong
 * @date 2020年6月10日
 */
public class AsynInvoker {

	public static void main(String[] args) throws InterruptedException {
		FutureService futureService = new FutureService();
//		Future<String> future = futureService.submit(() -> {
		futureService.submit(() -> {
			try {
				Thread.sleep(10000L);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return "FINISH";
		}, System.out::println);

		System.out.println("========");
		System.out.println("do other thing.");
		Thread.sleep(1000);
		System.out.println("========");
//		System.out.println(future.get());
	}

}
